package com.ghpt.controller;
import com.ghpt.pojo.DianWang;
import com.ghpt.service.DianWangService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

@RestController
@RequestMapping("/dianwang")
public class DianWangController {
    private final DianWangService dianWangService;

    public DianWangController(DianWangService dianWangService) {
        this.dianWangService = dianWangService;
    }
    @GetMapping("/{id}")
    public DianWang getDianWangById(@PathVariable Long id) {
        System.out.println("结果是"+dianWangService.findDianWangById(id));
        return dianWangService.findDianWangById(id);
    }
    @PutMapping
    public int updateDianWang(@RequestBody DianWang dianWang) {
        return dianWangService.updateById(dianWang);
    }
}
